<!doctype html>
<html>
<head>
<include file="public:headtop" />
    <link href="/static/css/general.css" rel="stylesheet">
<link href="static/css/center.css" rel="stylesheet">
</head>

<body>
	<include file="public:headmini" />
    <div class="order-box">
    	<div class="order ope">我的订单<span><a href="{:U('User/order')}">详情</a></span></div>
        <table class="media">
            <volist name="item_orders" id="vo">
                <tr>
                    <td>
                        <a href="{:U('Item/order', array('id' => $vo['id']))}">
                        <h3 class="media-title">
                            <span class="float-right media-date">{: date('y-m-d H:i', $vo['add_time']);}</span>
                            <span class="text-red">{$vo.sn}</span>
                        </h3>
                        <div class="media-text">
                            <span class="media-text-item">数量：{$vo.num}</span>
                            <span class="media-text-item">金额：￥{$vo.price}</span>
                            <span class="media-text-item">状态：<?php echo $status_arr[$vo['status']]; ?>  </span>
                        </div>
                        </a><if condition="$vo['status'] eq 0 "> <span class="media-text"><a onclick="delOrder({$vo['id']})"> 删除订单</a></span></if>
                        
                    </td>
                </tr>
            </volist>
        </table>
    </div>
	<div class="order-box">
    	<div class="order ope">我的购物车<span><a href="{:U('User/cars')}">详情</a></span></div>
        <div class="media-list">
            <volist name="item_car" id="vo">
                <a href="{: U('Item/index', array('id' => $vo['gid']))}">
                    <div class="media">
                        <h3 class="media-title text-tract">{$vo.goods}</h3>
                        <span class="media-text">
                            <span class="media-text-item">类型：{$vo.cate}</span>
                            <span class="media-text-item">数量：2</span>
                            <span class="media-text-item">单价：￥{$vo.price}</span>
                        </span>
                    </div>
                </a>
            </volist>
        </div>
    </div>
	<div class="order-box">
    	<div class="order ope">我的收藏<span><a href="{:U('User/coll')}">详情</a></span></div>
        <div class="media-list">
            <volist name="item_collection" id="vo">
                <a href="{: U('Item/index', array('id' => $vo['gid']))}">
                    <div class="media">
                        <h3 class="media-title text-tract">
                            {$vo.goods}
                        </h3>
                    <span class="media-text">
                        <span class="media-text-item">单价：￥{$vo.price}</span>
                    </span>
                    </div>
                </a>
            </volist>
        </div>
    </div>
   <!--  <div class="income-box">
    	<div class="income ope">我的奖励收入<span><a href="{:U('User/shouru')}">详情</a></span></div>
        <div class="shu"><span class="qian">￥</span>{$rebate.0}<span class="ling">.{$rebate.1}</span></div>
    </div> -->
    <div class="information-box">
    	<div class="income ope">我的信息<span><a href="{:U('mod')}">修改</a></span></div>

        <div class="container">
            <div class="text-center" style="margin-top: 18px;">
                <div class="avatar">
                    <img src="{$user_head_img}" alt="头像" id="a1">
                </div>
                <p id="a2">点击更换</p>
            </div>
            <div class="nr-box" data-iden="{$userinfo.is_identify}">
                <empty name="userinfo.is_identify">
                    <p class="friend-tip">您还未认证，点击 <a href="{:U('mod')}" class="link">补充认证资料</a></p>
                    <else/>
                    <ul>
                        <li class="li01"><p class="name"><span>姓</span>名</p><p class="ts">{$userinfo.truename}</p></li>
                        <li><p class="name">身份证号</p><p class="ts">{$userinfo.idcard}</p></li>
                        <li><p class="name">电话号码</p><p class="ts">{$userinfo.tel}</p></li>
                       <!--  <li class="top"><p class="name">银行账号</p><p class="ts">{$userinfo.bankaccount}</p></li>
                        <li class="li02"><p class="name">开户行</p><p class="ts">{$userinfo.bankname}</p></li> -->
                        <!--<li class="li03"><p class="name">支付宝</p><p class="ts">XXX@xxX.XXX</p></li>-->
                    </ul>
                </empty>
            </div>
        </div>

    </div>

    <div class="container" style="margin: 3rem auto;">
        <a class="btn btn-block" href="{:U('User/logout')}">退出</a>
    </div>

    <script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="/static/assets/form.js"></script>

<script>

    (function() {
        var config = {debug: false};
        config.url = "{$js.url}";
        config.appId = '{$js.appId}';
        config.timestamp = '{$js.timestamp}';
        config.nonceStr = '{$js.nonceStr}';
        config.signature = '{$js.signature}';
        config.jsApiList = ['chooseImage', 'uploadImage'];
        wx.config(config);
    })();

    $(function() {
        //微信上传图片
        $('#a1').WxUpload(function(serverId) {
            $.getJSON("{:U('headimg')}&mediaId=" + serverId, function(data) {
                if(data.status == 0) {
                    alert(data.info)
                } else {
                    location.reload();
                }
            });
        });
    });

    function delOrder(id){
        if (!confirm('你确定要删除此订单吗?')) {
          return false;
        }
        var url = "{:U('Order/del')}"+"&oid="+id;
        $.getJSON(url,function(data){
            if (data['code']==1) {
                // alert(data['msg']);
            }

            alert(data['msg']);
            window.location.reload();
            
        });
    }




	$('#a2').click(function(){
		$('#b1').trigger('click');
	})
	$('.showorderinfo').click(function(){
		var id = parseInt($(this).attr('data'));
		if(id>0 && typeof(id)=='number'){
			location.href="{:U('Item/order')}&id="+id;
		}else{
			alert('请确认提供的数据的准确性！');
		}
	})
	$('.showItem').click(function(){
		var id = parseInt($(this).attr('data'));
		var gid = parseInt($(this).attr('goods'));
		var ty = $(this).attr('ty');
		if(id>0 && typeof(id)=='number' && gid>0 && typeof(gid)=='number'){
			location.href="{:U('Item/jiesuan')}&id="+gid+"&od="+id+"&f="+ty;
		}else{
			alert('请确认提供的数据的准确性！');
		}
	})
	$('.showgoodsinfo').click(function(){
		var id = parseInt($(this).attr('data'));
		if(id>0 && typeof(id)=='number'){
			location.href="{:U('Item/index')}&id="+id;
		}else{
			alert('请确认提供的数据的准确性！');
		}
	})
	$('.c_usertype').click(function(){
		var t = $(this).attr('data');
		if(t=='汽车膜' || t=='建筑膜'){
			$.post(
				"{:U('User/modusertype')}",
				{'t':t},
				function(ref){
					ref = eval("("+ref+")");
					if(ref.status){
						location.reload();
					}else{
						alert('修改失败');
					}
				}
			);
		}else{
			alert('提交数据有误');
		}
	})
	$('#b1').change(function(){
		var v = $(this).val();
		var reader = new FileReader();
		reader.readAsDataURL(this.files[0]);
				reader.onload = function(e){
					console.log(e.target.result);
					//上传服务器
					$.post(
						"{:U('User/modheadimg')}",
						{'img':e.target.result},
						function(ref){
							ref = eval("("+ref+")");
							if(ref.status){
								//上传成功后更新本地
								$('#a1').attr('src',e.target.result);
								$('.portrait-box>a>img').attr('src',e.target.result);
								alert('更新成功');
							}else{
								alert('更新失败');
							}
						}
					);
				};
	})
</script>    
</body>
</html>